<?php

class Sys_EventLogController extends Zend_Controller_Action
{

    private $request;
	private $common;
	private $db;
    public function init()
    {
		$this->request = $this->getRequest();

		include_once "../library/inc/Zyt_Common.php"; 
		$this->common = Zyt_Common::getInstance();
		
		$this->common->checklogin(true, true);

		include_once "../library/inc/Db_Config.php";
		$this->db = Db_Config::getInstance()->Base();
        /* Initialize action controller here */
    }
	
	public function getlistAction(){
		$paging = array();
		$paging["start"] = $this->request->getParam("start");
		$paging["limit"] = $this->request->getParam("limit");

		$where = "";
		$_iAmount = $this->db->fetchOne("SELECT count(*) FROM syseventlog $where");
		//$paging["records"] = $_iAmount;
		//$page = Page::getInstance();
		//$paging = $page->getPaging($paging);
		$result = $this->db->fetchAll("SELECT * FROM syseventlog $where Limit $paging[start], $paging[limit]");

		$sMsg = "";
		$len = count($result);
		for($i=0; $i < $len; $i++) {
			$comma = ",";
			if($i == ($len -1)) 
			{
				$comma = "";
			}
			$sMsg .= "{RowID: ".$result[$i]["RowID"].",EvtID:" . $result[$i]["EvtID"] . ", EvtTypeTID:'" . $result[$i]["EvtTypeTID"] . "', EvtSourceTID:" . $result[$i]["EvtSourceTID"] . ", EvtCatalogTID: '" .$result[$i]["EvtCatalogTID"]. "', EvtModuleTID: '" . $result[$i]["EvtModuleTID"] . "', EvtSubject: '".$result[$i]["EvtSubject"]."', EvtData:'" . $result[$i]["EvtData"] . "', OptionSet: " . $result[$i]["OptionSet"] . ",CreateOn:'" . $this->common->getLocaldate($result[$i]["CreateOn"]) . "', CreateByID: ".$result[$i]["CreateByID"].",CreateByName: '".$result[$i]["CreateByName"]."',IP:'".$result[$i]["IP"]."', Status:" . $result[$i]["Status"] . " }" . $comma;
		}

		$acl = array("aRead" => 1, "aNew" => 1, "aEdit" => 1, "aLock" => 1, "aDel" => 1, "aList" => 1);
		$_sExtJSD = "Acl:[{aRead:" . $acl["aRead"] . ", aNew:" . $acl["aNew"] . ",aEdit:" . $acl["aEdit"] . ",aDel:" . $acl["aDel"] .
							  ",aList:" . $acl["aList"] . "}]";
		$this->common->PutData('{totalProperty:' . $_iAmount . ',records:[' . $sMsg . '],' . $_sExtJSD . '}');
		exit;
	}

}

